package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xmy.cultivate.enums.SourseLeveEnum;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author baomidou
 * @since 2022-08-07
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Select("select * from role ${ew.customSqlSegment}")
    public abstract List<Role> allRole(@Param(Constants.WRAPPER) Wrapper wrapper);


    @Select("select IFNULL(MAX(sourse_leve),0) as sourse_leve from role where id in(SELECT role_id from role_admin where admin_id = ${adminId})")
    public  abstract SourseLeveEnum getSourseLeve(@Param("adminId") Long adminId);

}
